import { Config } from "./config";

class Errors {
    argumentNull(argName: string): Error {
        let error = new Error(`Argument ${argName} cannot be null or undefined.`);
        error.name = Errors.prototype.argumentNull.name;
        return error;
    }
    pathNotExists(path: string): Error {
        let error = new Error(`Path ${path} does not exist.`);
        error.name = Errors.prototype.pathNotExists.name;
        return error;
    }
    configMissingField(fieldName: keyof Config) {
        let error = new Error(`Config file is missing field ${fieldName as string}.`);
        error.name = Errors.prototype.configMissingField.name;
        return error;
    }
    configInvalidType(fieldName: keyof Config, expectedType: string) {
        let error = new Error(`Config field ${fieldName as string} should be of type ${expectedType}.`);
        error.name = Errors.prototype.configInvalidType.name;
        return error;
    }
    connectionNotFound(connectionName: string): Error {
        let error = new Error(`Connection ${connectionName} not found in config file.`);
        error.name = Errors.prototype.connectionNotFound.name;
        return error;
    }
    tableConfigNotFound(tableName: string, fileName: string) {
        let error = new Error(`Table ${tableName} not found in database config file ${fileName}.yaml.`);
        error.name = Errors.prototype.tableConfigNotFound.name;
        return error;
    }
    tableNameShouldBeLowerCase(tableName: string) {
        let error = new Error(`Table name ${tableName} should be in lower case.`);
        error.name = Errors.prototype.tableNameShouldBeLowerCase.name;
        return error;
    }
    columnNameShouldBeLowerCase(columnName: string) {
        let error = new Error(`Column name ${columnName} should be in lower case.`);
        error.name = Errors.prototype.columnNameShouldBeLowerCase.name;
        return error;
    }
}

let errors = new Errors();
export default errors;